﻿<!DOCTYPE html>
<html>
  <head>
    <title>updatecommodity</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <link href="resources/css/jquery-ui-themes.css" type="text/css" rel="stylesheet"/>
    <link href="resources/css/axure_rp_page.css" type="text/css" rel="stylesheet"/>
    <link href="data/styles.css" type="text/css" rel="stylesheet"/>
    <link href="files/updatecommodity/styles.css" type="text/css" rel="stylesheet"/>
    <script src="resources/scripts/jquery-1.7.1.min.js"></script>
    <script src="resources/scripts/jquery-ui-1.8.10.custom.min.js"></script>
    <script src="resources/scripts/prototypePre.js"></script>
    <script src="data/document.js"></script>
    <script src="resources/scripts/prototypePost.js"></script>
    <script src="files/updatecommodity/data.js"></script>
    <link rel="stylesheet" type="text/css" href="./css/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="./css/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="./css/component.css" />
    <script src="./js/jquery.min.js" type="text/javascript"></script> 
    <script src="./js/jquery.easyui.min.js"></script> 
    <script type="text/javascript">
      $axure.utils.getTransparentGifPath = function() { return 'resources/images/transparent.gif'; };
      $axure.utils.getOtherPath = function() { return 'resources/Other.html'; };
      $axure.utils.getReloadPath = function() { return 'resources/reload.html'; };
    </script>
  </head>
  <body>
    <!-- 页面div元素显示位置设置 -->
    <div id="base" class="" style="text-align:center;position:absolute;margin:30px;">

     

      <table id="dg" class="easyui-datagrid" title="维护下架商品" style="width:1082px;height:auto;" data-options="singleSelect:true,collapsible:false,url:'/BackstageCommodity/showCommodity',method:'get',pagination:true,rownumbers: false,iconCls:'icon-edit',toolbar:'#tb',onClickRow: onClickRow">
        <thead>
          <tr>
              <!-- ,editor:{type:'datebox',options:{formatter:ww4,parser:w4}} -->
              <th data-options="field:'commodityId',width:80">商品编号</th>
              <th data-options="field:'commodityName',width:80">商品名</th>
              <th data-options="field:'commodityThumbnail',width:80">商品缩略图</th>
              <th data-options="field:'commodityPrise',width:100">商品价格</th>
              <th data-options="field:'commodityTarget',width:80">商品目标</th>
              <th data-options="field:'commodityComplete',width:80">商品完好程度</th>
              <th data-options="field:'commodityDescribe',width:100">商品描述</th>
              <th data-options="field:'commodityState',width:100">商品状态</th>
              <th data-options="field:'userId',width:100">用户id</th>
              <!-- ,formatter:function(value,row){return row.valueField;},editor:{type:'combobox',options:{valueField:'productid',textField:'productname',data:[{'productid':0,'productname':'未上架'},{'productid':1,'productname':'已上架'},{'productid':2,'productname':'已售出'}],required:true,panelHeight:'auto'}} -->
          </tr>
        </thead>
      </table>
      <div id="tb" style="height:auto">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">下架</a>
      </div>
      <script type="text/javascript">
        var editIndex = undefined;
        function endEditing(){
          if (editIndex == undefined){return true}
          if ($('#dg').datagrid('validateRow', editIndex)){
            $('#dg').datagrid('endEdit', editIndex);
            editIndex = undefined;
            return true;
          } else {
            return false;
          }
        }
        function onClickRow(index){
          if (editIndex != index){
            if (endEditing()){
              $('#dg').datagrid('selectRow', index)
                  .datagrid('beginEdit', index);
              editIndex = index;
            } else {
              $('#dg').datagrid('selectRow', editIndex);
            }
          }
        }
        function accept(){
          var row = $('#dg').datagrid('getSelected');
          if (row){
            var sendData = {
              commodityId:row.commodityId
            }
            $.ajax({
              type:'get',
              url:'/BackstageCommodity/frozeCommodity',
              data:sendData,
            });
            window.location.href = './groundingcommodity.html';
          }
        }
      function ww4(date){  
        var y = date.getFullYear();  
        var m = date.getMonth()+1;  
        var d = date.getDate();  
        // var h = date.getHours();  
        return  y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);  
                
          }  
          function w4(s){  
              var reg='-'; //利用正则表达式分隔  
              var ss = (s.split(reg));  
              var y = parseInt(ss[0],10);  
              var m = parseInt(ss[1],10);  
              var d = parseInt(ss[2],10);  
              // var h = parseInt(ss[3],10);  
              if (!isNaN(y) && !isNaN(m) && !isNaN(d)){  
                  return new Date(y,m-1,d);  
              } else {  
                  return new Date();  
              }  
          }  
      </script>
    </div>
  </body>
</html>
